function [accval, model] = BCCCE(r1, ensemble, truelabel, k, k_hat, MAXCOUNT)

% BC3E
% Bayesian Classification and Clustering Ensemble


% clc;
% clear global variables;

format short;
warning('off');



if(nargin<4)
 k        = 2;
 k_hat    = 4;
 MAXCOUNT = 20;
end

MaxFun   = 40;
param    = 1;
pcnt     = 100;

MAXESTEPITER = 10;
MAXMSTEPITER = 10;


%orgdata = load(filename);
data    = dataforBCCCE(r1, ensemble, truelabel, k, k_hat);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%data = gendataforBCCCE(k, pcnt);
%data = gendatafordblp(param);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % load Iris_clusterEnsemlbe_data.mat;
% % %base_labels,Palpha,Pbeta,PramaLap,number_baseclusterers
% % 
% % [N, ensm]=size(base_labels);
% % 
% % for i=1:ensm
% %    
% %    T = base_labels(:,i);
% %    sz= size(unique(T),1);
% %    
% %    temp  = zeros(N,sz);
% %    temp  = temp';
% %    temp2 = T+sz*[0:N-1]';
% %    temp(temp2)=1;
% %     
% %    dataw1(i).w = temp';
% %    dataw2(i).w = temp';
% %    
% % end
% % 
% % data.dataw1 = dataw1;
% % data.dataw2 = dataw2;
% % data.r1     = ensm;
% % data.r2     = ensm;
% % data.truelabel=true_labels;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%data=gensynthdataBC3E(N, k, k_hat, cla_ensm, clu_ensm);
%data=datanwsgrp1BC3E();

%data       = synthBC3E(N, k, cla_ensm);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

[model, accval] = variational_EM(data, MAXCOUNT, MAXESTEPITER, MAXMSTEPITER, MaxFun); 


end

